using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Accountability4net;

namespace Accountability4net.Client.Controls
{
    public partial class AccountsViewControl : UserControl
    {
        public AccountsViewControl()
        {
            InitializeComponent();
        }

        public AccountsViewControl(IList<IAccount> accounts)
            :this()
        {
            RefreshData(accounts);
        }

        public void RefreshData(IList<IAccount> accounts)
        {
            DataTable dataTable = new DataTable();
            dataTable.Columns.Add("Number", typeof(int));
            dataTable.Columns.Add("Name", typeof(string));
            dataTable.Columns.Add("Type", typeof(AccountType));
            foreach (IAccount account in accounts)
            {
                dataTable.Rows.Add(account.Number, account.Name, account.Type);
            }
            accountsDataGridView_.DataSource = dataTable;
        }
    }
}
